home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-9.10-netbook-remix-PL.iso / casper / filesystem.squashfs / etc / grub.d / 10_linux < prev    next >
Text File  |  2009-10-23  |  4KB  |  123 lines

  1. #! /bin/sh -e
  2.  
  3. # grub-mkconfig helper script.
  4. # Copyright (C) 2006,2007,2008,2009  Free Software Foundation, Inc.
  5. #
  6. # GRUB is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # GRUB is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  18.  
  19. prefix=/usr
  20. exec_prefix=${prefix}
  21. libdir=${exec_prefix}/lib
  22. . ${libdir}/grub/grub-mkconfig_lib
  23.  
  24. if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
  25.   OS=GNU/Linux
  26. else
  27.   OS="${GRUB_DISTRIBUTOR}"
  28. fi
  29.  
  30. # loop-AES arranges things so that /dev/loop/X can be our root device, but
  31. # the initrds that Linux uses don't like that.
  32. case ${GRUB_DEVICE} in
  33.   /dev/loop/*|/dev/loop[0-9])
  34.     GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
  35.     # We can't cope with devices loop-mounted from files here.
  36.     case ${GRUB_DEVICE} in
  37.       /dev/*) ;;
  38.       *) exit 0 ;;
  39.     esac
  40.   ;;
  41. esac
  42.  
  43. if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
  44.     || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
  45.     || [ "`grub-probe -t abstraction --device ${GRUB_DEVICE} | sed -e 's,.*\(lvm\).*,\1,'`" = "lvm"  ] ; then
  46.   LINUX_ROOT_DEVICE=${GRUB_DEVICE}
  47. else
  48.   LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
  49. fi
  50.  
  51. # add crashkernel option if we have the required tools
  52. if [ -x "/usr/bin/makedumpfile" ] && [ -x "/sbin/kexec" ]; then
  53.     GRUB_CMDLINE_EXTRA="$GRUB_CMDLINE_EXTRA crashkernel=384M-2G:64M,2G-:128M"
  54. fi
  55.  
  56. linux_entry ()
  57. {
  58.   cat << EOF
  59. menuentry "$1" {
  60.         recordfail=1
  61.         if [ -n \${have_grubenv} ]; then save_env recordfail; fi
  62. EOF
  63.   if [ "x$3" = "xquiet" ]; then
  64.     cat << EOF
  65.     set quiet=1
  66. EOF
  67.   fi
  68.   save_default_entry | sed -e "s/^/\t/"
  69.   prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
  70.   cat << EOF
  71.     linux    ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro $2
  72. EOF
  73.   if test -n "${initrd}" ; then
  74.     cat << EOF
  75.     initrd    ${rel_dirname}/${initrd}
  76. EOF
  77.   fi
  78.   cat << EOF
  79. }
  80. EOF
  81. }
  82.  
  83. list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do
  84.         if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
  85.       done`
  86.  
  87. while [ "x$list" != "x" ] ; do
  88.   linux=`version_find_latest $list`
  89.   echo "Found linux image: $linux" >&2
  90.   basename=`basename $linux`
  91.   dirname=`dirname $linux`
  92.   rel_dirname=`make_system_path_relative_to_its_root $dirname`
  93.   version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
  94.   alt_version=`echo $version | sed -e "s,\.old$,,g"`
  95.   linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
  96.  
  97.   initrd=
  98.   for i in "initrd.img-${version}" "initrd-${version}.img" \
  99.        "initrd-${version}" "initrd.img-${alt_version}" \
  100.        "initrd-${alt_version}.img" "initrd-${alt_version}"; do
  101.     if test -e "${dirname}/${i}" ; then
  102.       initrd="$i"
  103.       break
  104.     fi
  105.   done
  106.   if test -n "${initrd}" ; then
  107.     echo "Found initrd image: ${dirname}/${initrd}" >&2
  108.   else
  109.     # "UUID=" magic is parsed by initrds.  Since there's no initrd, it can't work here.
  110.     linux_root_device_thisversion=${GRUB_DEVICE}
  111.   fi
  112.  
  113.   linux_entry "${OS}, Linux ${version}" \
  114.       "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_EXTRA} ${GRUB_CMDLINE_LINUX_DEFAULT}" \
  115.       quiet
  116.   if [ "x${GRUB_DISABLE_LINUX_RECOVERY}" != "xtrue" ]; then
  117.     linux_entry "${OS}, Linux ${version} (recovery mode)" \
  118.     "single ${GRUB_CMDLINE_LINUX}"
  119.   fi
  120.  
  121.   list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
  122. done
  123.